$(function () {
    // 页面跳转
    var navlists = $(".nav-list .item");
    navlists.eq(0).click(function () {
        location.href = "./index.html"
    })
    navlists.eq(1).click(function () {
        location.href = "./news.html"
    })
    navlists.eq(2).click(function () {
        location.href = "./valkyries.html"
    })
    navlists.eq(3).click(function () {
        location.href = "./wallpapers.html"
    })
    navlists.eq(4).click(function () {
        location.href = "./merch.html"
    })
    // $.cookie("username", "汤原儿");

    // 用户是否登录
    var nouser = $(".nouser");
    var hasuser = $(".hasuser");
    function login() {
        if ($.cookie('username') != null) {
            var username = $.cookie('username');
            hasuser.children().eq(0).text(username);
            hasuser.children().eq(0).on("click",function(){
                location.href = "./cart.html"
            })
            nouser.css({ "display": "none" })
            hasuser.css({ "display": "block" })
        } else {
            hasuser.children().eq(0).off("click");
            hasuser.css({ "display": "none" })
            nouser.css({ "display": "block" })
        }
    }
    login();

    var logout = hasuser.children().eq(1);
    logout.click(function () {
        $.removeCookie('username');
        login()
    })


})